﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Data;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Imaging;
using System.Windows.Navigation;
using System.Windows.Shapes;
using Kmust.App_Data.KmustDataTableAdapters;
using Kmust.Commom;

namespace Kmust.KmustControl
{
    /// <summary>
    /// TeacherControl.xaml 的交互逻辑
    /// </summary>
    public partial class TeacherControl : UserControl
    {
        Kmust.App_Data.KmustData.JSDataTable jsd = new App_Data.KmustData.JSDataTable();
        KmustPager Page = new KmustPager();
        
        //组件代码初始化
        private void initDate()
        {
            using (JSTableAdapter js = new JSTableAdapter())
            {
                jsd = js.GetData();
            }
        }


        //自定义属性
        public static readonly DependencyProperty setSourceProperty = DependencyProperty.Register("setSource", typeof(string), typeof(StudentControl), null);

        //定义组织机构代码号
        private string setsource;
        //公开组织机构代码号
        public string setSource
        {
            get { return setsource; }
            set
            {
                if (value != null)
                {
                    setsource = value;
                    // StudentGrid.ItemsSource =xsd.Where(row=>row.ZZJGM.Equals(value)).Take(Page.PageSize);
                    //当前页置零
             //       Page.PageCurrent = 0;
                    //即第一页
                    setNewSource();
                    //  MessageBox.Show(value);
                }
            }
        }
        //设值组织机构代码
        private void setNewSource()
        {
            TeacherGrid.ItemsSource = jsd.Where(row => row.ZZJGM.Equals(setSource)).Take(15);
            this.UpdateLayout();
        }

        //UI数据更新
        public void upDate(string value)
        {
            //page.NMax=xsd.TableName("XS").
            //Page.NMax = xsd.Count(row => row.ZZJGM.Equals(value));
            //// Page.PageCurrent = 1;
            //AllCountLabel.Content = "总记录数：" + Page.NMax.ToString();
            //CountLabel.Content = "总页数: " + Page.PageCount;
            //CurrentLabel.Content = "当前页:" + (Page.PageCurrent + 1).ToString();
        }

        //组件初始化系统自带
        public TeacherControl()
        {
            InitializeComponent();
            initDate();
        }
        

        private void CheckBox_Click_1(object sender, RoutedEventArgs e)
        {

        }
    }
}
